package org.htmlparser.parserapplications.filterbuilder;

import java.util.Vector;
import javax.swing.event.TreeModelListener;
import javax.swing.tree.TreeModel;
import org.htmlparser.Node;
import org.htmlparser.tags.Html;
import org.htmlparser.util.NodeList;

public class HtmlTreeModel
  implements TreeModel
{
  protected Node mRoot;
  protected Vector mTreeListeners = new Vector();

  public HtmlTreeModel(NodeList paramNodeList)
  {
    this.mRoot = new Html();
    this.mRoot.setChildren(paramNodeList);
  }

  public void addTreeModelListener(TreeModelListener paramTreeModelListener)
  {
    synchronized (this.mTreeListeners)
    {
      if (!(this.mTreeListeners.contains(paramTreeModelListener)))
        this.mTreeListeners.addElement(paramTreeModelListener);
      return;
    }
  }

  public Object getChild(Object paramObject, int paramInt)
  {
    NodeList localNodeList = ((Node)paramObject).getChildren();
    if (localNodeList == null)
      throw new IllegalArgumentException("invalid parent for getChild()");
    return localNodeList.elementAt(paramInt);
  }

  public int getChildCount(Object paramObject)
  {
    int i = 0;
    NodeList localNodeList = ((Node)paramObject).getChildren();
    if (localNodeList != null)
      i = localNodeList.size();
    return i;
  }

  public int getIndexOfChild(Object paramObject1, Object paramObject2)
  {
    int i = -1;
    NodeList localNodeList = ((Node)paramObject1).getChildren();
    if (localNodeList != null)
    {
      int j = localNodeList.size();
      int k = 0;
      while (true)
      {
        if (k < j)
        {
          if (paramObject2 != localNodeList.elementAt(k))
            break label64;
          i = k;
        }
        if (i >= 0)
          break label80;
        throw new IllegalArgumentException("child not found in getIndexOfChild()");
        label64: ++k;
      }
    }
    throw new IllegalArgumentException("invalid parent for getIndexOfChild()");
    label80: return i;
  }

  public Object getRoot()
  {
    return this.mRoot;
  }

  public boolean isLeaf(Object paramObject)
  {
    int i;
    NodeList localNodeList = ((Node)paramObject).getChildren();
    if (localNodeList == null)
    {
      i = 1;
      label16: return i;
    }
    if (localNodeList.size() == 0)
      i = 1;
    while (true)
    {
      break label16:
      i = 0;
    }
  }

  public void removeTreeModelListener(TreeModelListener paramTreeModelListener)
  {
    synchronized (this.mTreeListeners)
    {
      this.mTreeListeners.removeElement(paramTreeModelListener);
      return;
    }
  }

  // ERROR //
  public void valueForPathChanged(javax.swing.tree.TreePath paramTreePath, Object paramObject)
  {
    // Byte code:
    //   0: new 82	javax/swing/event/TreeModelEvent
    //   3: dup
    //   4: aload_0
    //   5: aload_1
    //   6: invokespecial 85	javax/swing/event/TreeModelEvent:<init>	(Ljava/lang/Object;Ljavax/swing/tree/TreePath;)V
    //   9: astore_3
    //   10: aload_0
    //   11: getfield 20	org/htmlparser/parserapplications/filterbuilder/HtmlTreeModel:mTreeListeners	Ljava/util/Vector;
    //   14: astore 4
    //   16: aload 4
    //   18: monitorenter
    //   19: aload_0
    //   20: getfield 20	org/htmlparser/parserapplications/filterbuilder/HtmlTreeModel:mTreeListeners	Ljava/util/Vector;
    //   23: invokevirtual 88	java/util/Vector:clone	()Ljava/lang/Object;
    //   26: checkcast 17	java/util/Vector
    //   29: astore 6
    //   31: aload 4
    //   33: monitorexit
    //   34: iconst_0
    //   35: istore 7
    //   37: iload 7
    //   39: aload 6
    //   41: invokevirtual 89	java/util/Vector:size	()I
    //   44: if_icmpge +33 -> 77
    //   47: aload 6
    //   49: iload 7
    //   51: invokevirtual 92	java/util/Vector:elementAt	(I)Ljava/lang/Object;
    //   54: checkcast 94	javax/swing/event/TreeModelListener
    //   57: aload_3
    //   58: invokeinterface 98 2 0
    //   63: iinc 7 1
    //   66: goto -29 -> 37
    //   69: astore 5
    //   71: aload 4
    //   73: monitorexit
    //   74: aload 5
    //   76: athrow
    //   77: return
    //
    // Exception table:
    //   from	to	target	type
    //   19	34	69	finally
    //   71	74	69	finally
  }
}